<template>
	<!-- 订单生成 -->
	<div>
		<div class="edit-top">
			生成信息
			<i class="el-icon-close" @click='cancel'></i>
		</div>
		<div class="edit-content">
			<div class="edit-title">换电后</div>
			<div class="edit-item" >
				<label>换电公里数</label><input v-model="switchMileage" type="text" />
			</div>
			<div class="edit-item" >
				<label>剩余公里数</label><input v-model="afterSwitchRemainingMileage" type="text" />
			</div>
		</div>
		<div class="edit-bottom">
			<span @click='cancel'>取消</span>
			<el-button @click='save' type="primary">保存</el-button>
		</div>
	</div>
</template>

<script>
	import Global from '@/components/Global.vue'
	export default {
		props: ['id'],
		data() {
			return {
				switchMileage:'',
				afterSwitchRemainingMileage:'',
				dep_list: [],
				info: {
					name: '',
					code: '',
					parentId: 0,

				}
			}
		},
		mounted() {
			this.get_info();
		},
		methods: {
			//获取详情
			get_info() {
				var self = this;
				this.$axios.get(this.$global.serverIp + 'vehicle/vehicle/plateOrVinGetInfo/'+this.id)
					.then(function(res) {
						if (res != '')
							self.info = res.data;
							// self.param.vehicleId = res.data.vehicle.id;
							// self.param.vehicleLicenseNumber = res.data.vehicle.licensePlateNumber;
							// self.param.vehicleVin = res.data.vehicle.vin;
							// self.param.memeberUsername = res.data.client.sysUser.userName;
							// self.param.memberId = res.data.client.userId;
							// self.param.stationId = res.data.station.id;
							// console.log(self.param);
							// self.is_show = true;
					})
			},
			
			//点击保存
			save() {
				if (this.switchMileage == "") {
					this.$popup.open('换电公里数不能为空');
					return;
				}
				if (this.afterSwitchRemainingMileage == "") {
					this.$popup.open('换电后剩余公里数不能为空');
					return;
				}
				var info = {
					"processId": this.info.order.processId,
					"taskId":this.info.order.taskId,
					"tableId":this.info.order.tableId,
					"switchMileage":this.switchMileage,
					"afterSwitchRemainingMileage":this.afterSwitchRemainingMileage
				}
				console.log(info);
				var self = this;
				this.$axios.post(this.$global.serverIp + 'order/order/saveOrderGetPay', info)
					.then(function(res) {
						if (res != '') {
							self.success('生成成功');
						}
					})
			},
			//添加成功
			success(content) {
				var self = this;
				this.$alert(content, '提示', {
					confirmButtonText: '确定',
					callback: action => {
						self.$emit("saveEdit", 2);
					}
				});
			},
			//点击取消
			cancel() {
				this.$emit("saveEdit", 1);
			}
		}
	}
	import '@/assets/css/edit.css'
</script>
